FROM ubuntu:18.04 AS builder
MAINTAINER https://github.com/wevsmy

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse' > /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y wget gcc libc6-dev libssl-dev ca-certificates make --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
wget https://github.com/ntop/n2n/archive/2.4.tar.gz && \
tar -zxvf 2.4.tar.gz && \
cd n2n-2.4 && \
make

FROM ubuntu:18.04
MAINTAINER https://github.com/wevsmy

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse' > /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y isc-dhcp-server net-tools inetutils-ping --no-install-recommends && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /n2n-2.4/supernode /usr/bin
COPY --from=builder /n2n-2.4/edge /usr/bin
COPY entrypoint.sh /

# main
EXPOSE 7654 7654/udp
# management
EXPOSE 5645 5645/udp

ENTRYPOINT ["/entrypoint.sh"]